﻿<?php
  @header("content-Type: text/html; charset=utf-8"); //语言强制
	require_once('header.php');
?>

<link rel="stylesheet" href="/css/table.css" type="text/css"/>

<table class="t1"> 
 
<?php
  $stockCode = $_GET['code'];
  
  // Connect to the database 
  $dbc = mysqli_connect('localhost', 'root', 'k00l@1D;', 'gudahu')
    or die('Error connecting to MySQL server.');
	mysqli_set_charset($dbc, 'utf8');
  // Retrieve the score data from MySQL
  $query = "SELECT * FROM top_holder where stock_code = ".$stockCode.' order by id';
  $result = mysqli_query($dbc, $query)
    or die('Error querying database.'); 
  $appearDate = '';
  $isLine2 = false;  
  while ($row = mysqli_fetch_array($result)) { 
  	  $currentAppearDate = $row['appear_date'];
  	  if ($currentAppearDate != $appearDate) {
  	  	echo '<tr><td colspan="4">&nbsp;</td></tr>';
  	  	echo '<tr><td colspan="4">'.$currentAppearDate.'</td></tr>';
  	  	echo '<thead><th>排名</th><th>股东</th><th>占股数量</th><th>占股比例</th></thead>';
  	  	$appearDate = $currentAppearDate;
  	  	$isLine2 = false;
  	  }
  	  
  	  if ($isLine2) {
  	  	echo '<tr class="a1">';
  	  	$isLine2 = false;
  	  } else {
  	  	echo '<tr>';
  	  	$isLine2 = true;
  	  }
  	  
      echo '<td>'.$row['rank'].'</td>';
      echo '<td>'.$row['holder_name'].'</td>';
      echo '<td>'.$row['share_amount'].'</td>';
      echo '<td>'.$row['share_ratio'].'%</td>';
      echo '</tr>';
  }					    
  mysqli_close($dbc);
?>

</table>

<?php
	require_once('footer.php');
?>  
